package com.adtech.adms.commons.file.service.impl;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicSize extends AtomicInteger {
	
	public AtomicSize() {
		super(0);
	}
	
	public AtomicSize(int initialValue) {
		super(initialValue);
    }
	
	public final int getAndDecrement(int delta) {
        for (;;) {
            int current = get();
            int next = current - delta;
            if (compareAndSet(current, next))
                return current;
        }
    }

}
